package com.powerunion.datacollection.quartz;

import java.util.*;
import org.quartz.*;

/**
 * 应用任务
 * @author qyw
 *
 */
public abstract class AppTask implements Job {
	private JobExecutionContext jobConetext;

	public AppTask() {
	}

	/**
	 * 获取上一次被执行的时间
	 * 
	 * @return Date
	 */
	public Date getPreviousFireTime() {
		return jobConetext.getPreviousFireTime();
	}

	/**
	 * 获取将被执行的时间
	 * 
	 * @return Date
	 */
	public Date getNextFireTime() {
		return jobConetext.getNextFireTime();
	}

	public Date getFireTime() {
		return jobConetext.getFireTime();
	}

	/**
	 * doTask－－执行任务的抽象方法，在此方法内实现任务代码
	 */
	public abstract void doTask();

	final public void execute(JobExecutionContext jobExecutionContext)
			throws JobExecutionException {
		this.jobConetext = jobExecutionContext;
		this.doTask();
	}

	public String getTaskName() {
		return this.jobConetext.getJobDetail().getName();
	}

	public JobExecutionContext getJobConetext() {
		return jobConetext;
	}

}
